import 'package:flutter/services.dart';

class VpnService {
  static const MethodChannel _channel = MethodChannel('com.example.vpn');

  // 连接 VPN
  static Future<bool> connectVpn(String username, String password) async {
    try {
      return await _channel.invokeMethod('connectVpn', {
        'username': username,
        'password': password,
      });
    } on PlatformException catch (e) {
      print("连接失败: ${e.message}");
      return false;
    }
  }

  // 断开 VPN
  static Future<bool> disconnectVpn() async {
    try {
      return await _channel.invokeMethod('disconnectVpn');
    } on PlatformException catch (e) {
      print("断开失败: ${e.message}");
      return false;
    }
  }
}

